﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Kugar.Core.WinForm.ScreenHelper
{
    public static class ScreenHelper
    {
        public static Bitmap TakeScreenShot()
        {
            Rectangle TotalScreenRect = Rectangle.Empty;
            foreach (Screen CurrentScreen in Screen.AllScreens)
            {
                TotalScreenRect = Rectangle.Union(TotalScreenRect, CurrentScreen.Bounds);
            }
            Bitmap TempBitmap = new Bitmap(TotalScreenRect.Width, TotalScreenRect.Height, PixelFormat.Format32bppArgb);
            using (Graphics TempGraphics = Graphics.FromImage(TempBitmap))
            {
                TempGraphics.CopyFromScreen(TotalScreenRect.X, TotalScreenRect.Y, 0, 0, TotalScreenRect.Size, CopyPixelOperation.SourceCopy);
            }
            return TempBitmap;
        }
    }
}
